
import java.awt.*;
import java.awt.print.Book;
import java.security.Key;
import java.util.Iterator;

import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

class BooK implements Comparable<BooK>{
    int bid;
    String bname;
    float price;

    public BooK(int bid, String bname, float price) {
        this.bid = bid;
        this.bname = bname;
        this.price = price;
    }

    @Override
    public String toString() {
        return "BooK{" +
                "bid=" + bid +
                ", bname='" + bname + '\'' +
                ", price=" + price +
                '}';
    }

    @Override
    public int compareTo(BooK o) {
        if(this.price>o.price){
            return -1;
        }
        return 1;
    }
}

public class test8 {
    public static void main(String[] args) {
        TreeMap<BooK,String> map =new TreeMap<>();
        map.put(new BooK(1,"西游记",100),"老白");
        map.put(new BooK(2,"东游记",120),"老三");
        map.put(new BooK(6,"红楼梦",150),"老二");
        map.put(new BooK(9,"水浒传",130),"老四");
        map.put(new BooK(5,"三国演义",300),"老五");
        Set<BooK> keySet = map.keySet();
        Iterator<BooK> it = map.keySet().iterator();
        while (it.hasNext()){
            BooK key  =it.next();
            String value =map.get(key);
            System.out.println(key+"---"+value);
        }
        for(Map.Entry<BooK,String> e:map.entrySet()){
            BooK key  =e.getKey();
            String value =e.getValue();
            System.out.println(key+"---"+value);
        }
//        System.out.println(map.comparator());
        }

}
